package com.atguigu03.list.exer2;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Random;

/**
 * ClassName: ListTest
 * Package: com.atguigu03.list.exer2
 * Description:
 *
 * @Author BuTang
 * @Create 2023/6/5 17:30
 * @Version 1.0
 */
public class ListTest {
    public static void main(String[] args) {
        ArrayList a = new ArrayList();
        for (int i = 0; i < 30; i++) {
            char type = (char) (Math.random() * 27 + 97);
            String s = String.valueOf(type);
            a.add(s);
            //System.out.println(type);
        }

        System.out.println(ListTest.listTest(a, "a"));
        System.out.println(ListTest.listTest(a, "b"));
        System.out.println(ListTest.listTest(a, "c"));
        System.out.println(ListTest.listTest(a, "x"));
    }

    public static int listTest(Collection list, String s) {
        int count = 0;
        for (Object o : list) {
            if (o.equals(s)) {
                count++;
            }
        }
        return count;


    }
}



